<template>
  <div>
    <div>
      <el-input v-model="logid" placeholder="请输入内容" @blur="inputarr" ></el-input>
    </div>
    <el-button type="danger" size="mini" @click="pishan()" style="margin-top:20px">删除</el-button>
    <el-button type="primary" size="mini" @click="search">查询</el-button>
    <el-table
      ref="multipleTable"
      :data="arr"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="60"></el-table-column>
      <el-table-column prop="logid" label="审核人id" width="120"></el-table-column>
      <el-table-column prop="username" label="审核人" width="120"></el-table-column>
      <el-table-column prop="v_id" label="采访人id" show-overflow-tooltip></el-table-column>
      <el-table-column prop="status" label="状态" show-overflow-tooltip></el-table-column>
      <el-table-column prop="visitor" label="来访人" show-overflow-tooltip></el-table-column>
      <el-table-column prop="mobile" label="来访人电话" show-overflow-tooltip></el-table-column>
      <el-table-column prop="card" label="来访人身份证" show-overflow-tooltip></el-table-column>
      <el-table-column prop="carnumber" label="来访人车牌号" show-overflow-tooltip></el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="xiangqing (scope.row.logid)">详情</el-button>

          <el-dialog title="审核人信息" :visible.sync="dialogTableVisible">
            <el-table :data="gridData">
              <el-table-column prop="username" label="姓名" width="200"></el-table-column>
              <el-table-column prop="logid" label="id" width="200"></el-table-column>
               <el-table-column prop="addtime" label="时间" width="200"></el-table-column>
              <el-table-column prop="userid" label="userid" width="200"></el-table-column>
            </el-table>
          </el-dialog>
          <el-button
            size="mini"
            type="danger"
            @click.native.prevent="deleteRow(scope.$index, arr)"
          >删除</el-button>
        </template>
      </el-table-column>
      <!-- 详情 -->
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[5, 10, 20, 25]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      gridData: [],
      dialogTableVisible: false,
      currentPage4: 4,
      tableData: [],
      page: 1,
      pageSize: 5,
      logid:'',
      total: 0,
      arr: [],
      id: "",
      ids: [],
      newids: [],
      multipleSelection: [],
      input: ''
    };
    
  },

  methods: {
    xiangqing(logid){
      this.dialogTableVisible=true
      this.$axios.get('http://121.42.230.80/api/visit/auditlog/show',{params:{id:logid}}
      ).then(
        res=>{
          console.log(res.data.data)
          this.gridData=[]
          this.gridData.push(res.data.data)
      } )
    },
    search(){
      this.$axios.get('http://121.42.230.80/api/visit/auditlog/list',{params:{logid:this.logid}}
      ).then(
        res=>{
         this.arr = [];
        this.arr=res.data.data;
        // console.log(res.data.data);
      } )
    },
    inputarr(){
      if (this.logid == "") {
        this.aa();
      }
    },
        handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      },
    
    // xq() {
    //     this.dialogVisible = true
    // },
    handleSizeChange(val) {
      this.pageSize = val;
      this.aa();
      console.log(val)
      console.log(this.pageSize)
    },
    handleCurrentChange(val) {
      this.page = val;
      this.aa();
       console.log(val)
    },
    aa() {
      this.$axios.get("http://121.42.230.80/api/visit/auditlog/list?pageSize="+this.pageSize + '&page='+this.page)
        .then(
          (res) => {
            console.log(res);
            if (res.data.code == "00000") {
              this.arr = res.data.data;
              console.log(res.data.total)
               this.total = res.data.total
            }
          },
          (err) => {
            console.log(err);
          }
        );
    },
    deleteRow(index, rows) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          console.log(index);
          console.log(rows);
          console.log(rows[index].logid);
          this.id = rows[index].logid;
          this.$axios
            .get("http://121.42.230.80/api/visit/auditlog/del", {
              params: {
                logid: this.id,
              },
            })
            .then(
              (res) => {
                console.log(res);
                if (res.data.code == "00000") {
                  this.aa();
                  this.$message({
                    type: "success",
                    message: "删除成功!",
                  });
                }
              },
              (err) => {
                console.log(err);
              }
            );
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },

    pishan() {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$axios
            .get("http://121.42.230.80/api/visit/auditlog/del", {
              params: {
                logid: this.ids,
              },
            })
            .then(
              (res) => {
                console.log(res);
                if (res.data.code == "00000") {
                  this.aa();
                  this.$message({
                    type: "success",
                    message: "删除成功!",
                  });
                }
              },
              (err) => {
                console.log(err);
              }
            );
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    handleSelectionChange(val) {
      for (var i in val) {
        this.ids.push(val[i].logid);
      }
    },

    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
  },
  created() {
    this.aa();
  },
};
</script>

<style>
</style>